<!--
 * @Descripttion: 
 * @version: 
 * @Author: ybac
 * @Date: 2022-06-20 11:13:15
 * @LastEditors: Please set LastEditors
 * @LastEditTime: 2023-06-07 17:52:23
-->
<template>
  <div>
    <a-modal
      :width="'40vw'"
      :visible="visible"
      :closable="false"
      :confirm-loading="false"
      @ok="save"
      @cancel="visible = false"
      :okText="type === 0 ? '确认同意' : '确认拒绝'"
    >
      <a-textarea :maxLength="500" v-model="formData.option" placeholder="请输入审批意见" :rows="7" />
      <div style="margin-top: 20px">
        <file-upload :ids="formData.attachment" @getFileList="getFileList"></file-upload>
        <p style="line-height: 30px;color:#8d8d8d;">最多上传5个文件，每个大小不可超过20M</p>
      </div>
      <template slot="footer">
        <a-button key="back" @click="visible = false">
          取消
        </a-button>
        <a-button key="submit" type="primary" :loading="loading" @click="save">
          {{type === 0 ? '确认同意' : '确认拒绝'}}
        </a-button>
      </template>
    </a-modal>
  </div>
</template>
<script>
import FileUpload from '@/components/fileActions/FileUpload.vue'
import { putAction } from '@/api/manage'
export default {
  data() {
    return {
      visible: false,
      type: 0, //0同意，1拒绝
      formData: {},
      url: {
        agree: '/proc/operate/agree',
        refuse: '/proc/operate/refuse',
      },
      loading:false
    }
  },
  components: { FileUpload },
  watch: {},
  created() {},
  mounted() {},
  methods: {
    getData(a, b, c) {
      this.visible = a
      this.formData.taskId = b
      this.type = c
      this.$forceUpdate()
    },
    getFileList(v) {
      this.formData.attachment = v
      console.log(this.formData, '上传的附件id：', v)
    },
    save() {
      console.log(this.formData, 'this.formData')
      this.loading=true
      putAction(this.type === 0 ? this.url.agree : this.url.refuse, this.formData).then((res) => {
        console.log(res, 'res')
        if (res.code === 200) {
          this.$antdMessage.success(res.message)
          this.formData = {}
          this.visible = false
          this.$emit('resultStatus', true)
        } else {
          this.$antdMessage.error(res.message)
          this.$emit('resultStatus', false)
        }
        this.visible = false
        this.loading=false
      })
    },
  },
}
</script>
<style scoped></style>
